import request from '@/utils/request';

/**
 * 分页查询海运散货
 */
export async function pageOceanBulkCargo(params) {
  const res = await request.get('/ocean/oceanBulkCargo/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询海运散货列表
 */
export async function listOceanBulkCargo(params) {
  const res = await request.get('/ocean/oceanBulkCargo', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询海运散货
 */
export async function getOceanBulkCargo(id) {
  const res = await request.get('/ocean/oceanBulkCargo/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加海运散货
 */
export async function addOceanBulkCargo(data) {
  const res = await request.post('/ocean/oceanBulkCargo', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改海运散货
 */
export async function updateOceanBulkCargo(data) {
  const res = await request.put('/ocean/oceanBulkCargo', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除海运散货
 */
export async function removeOceanBulkCargo(id) {
  const res = await request.delete('/ocean/oceanBulkCargo/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
